-----------------------------------------
-----------------------------------------
-----------------------------------------
1. DESCRIPTION

This is a replication folder for "Measuring Public Uncertainty about Candidate Ideology: An Application to US Presidential Elections." All of the files, data, and code necessary to replicate the figures, and empirical results in the article are present in this folder.

Version: November 10, 2019


-----------------------------------------
-----------------------------------------
-----------------------------------------
2. FITTED AM-SCALING SCALING MODELS

-----------------------------------------
2.1. ANES

To reproduce the fitted models for the ANES studies, change the paths as necessary in the following file and run the complete R code to generate the fitted models:

ANES_Sigma_Models.R


The resulting models will be outputted to the Fitted_Models/ directory as:

posterior_anes_1972.rds
posterior_anes_1976.rds
posterior_anes_1980.rds
posterior_anes_1984.rds
posterior_anes_1988.rds
posterior_anes_1992.rds
posterior_anes_1996.rds
posterior_anes_2000.rds
posterior_anes_2004.rds
posterior_anes_2008.rds
posterior_anes_2012.rds
posterior_anes_2016.rds

** NOTE: At the time of writing, the models fit to each year of the ANES data will take between 1 and 4 hours to fit depending on computational power.


-----------------------------------------
2.2. CCES

To reproduce the fitted models for the CCES studies, change the paths as necessary in the following files and execute each file:

CCES_Sigma_2008.R
CCES_Sigma_2008_PartyID.R

CCES_Sigma_2012.R
CCES_Sigma_2012_PartyID.R

CCES_Sigma_2016.R
CCES_Sigma_2016_PartyID.R


The resulting models will be outputted to the Fitted_Models/ directory as:

posterior_cces_2008.rds
posterior_cces_2008D.rds
posterior_cces_2008R.rds

posterior_cces_2012.rds
posterior_cces_2012D.rds
posterior_cces_2012R.rds

posterior_cces_2016.rds
posterior_cces_2016D.rds
posterior_cces_2016R.rds

** NOTE: At the time of writing, the models fit to the CCES data will take between 4-24 hours to fit depending on computational power. The models
fit to the CCES data were fit on a high-performance computing cluster, but can
in principle be also fit straightforwardly on a personal computer.


-----------------------------------------
-----------------------------------------
-----------------------------------------
3. ANALYSIS

-----------------------------------------

3.1. Figures

After fitting the models (or using the already-fitted model files included in
the replication data), change the paths as necessary in the following files and
run each file to generate figures in the main article and appendix:

ANES_Sigma_Analysis.R
CCES_Sigma_Analysis.R


3.2. Summary statistics and tables

All tables and summary statistics that are noted in the main article and 
appendix are also noted at the relevent line of code in each of the two files
above, i.e.:

ANES_Sigma_Analysis.R
CCES_Sigma_Analysis.R


-----------------------------------------
-----------------------------------------
-----------------------------------------
4. FILE MANIFEST

-----------------------------------------
(1) ANES_Sigma_Models.R        - Fits an AM-scaling model to each of the ANES
                                 datasets
(2) CCES_Sigma_2008.R.         - Fits an AM-scaling model to the 2008 CCES data
(3) CCES_Sigma_2008_PartyID.R. - Fits two AM-scaling models to the 2008 CCES
                                 data, one for Republican identifiers, another
                                 for Democratics identifiers
(4) CCES_Sigma_2012.R          - Fits an AM-scaling model to the 2012 CCES data
(5) CCES_Sigma_2012_PartyID.R  - Fits two AM-scaling models to the 2012 CCES
                                 data, one for Republican identifiers, another
                                 for Democratics identifiers
(6) CCES_Sigma_2016.R          - Fits an AM-scaling model to the 2016 CCES data
(7) CCES_Sigma_2016_PartyID.R  - Fits two AM-scaling models to the 2016 CCES
                                 data, one for Republican identifiers, another
                                 for Democratics identifiers
(9)  AM_Sigma.stan             - The .stan file defining the AM-scaling model
(10) ANES_Sigma_Analysis.R     - Generates the figures, tables, and summary
                                 statistics included in the main article and
                                 appendix for the ANES data
(11) CCES_Sigma_Analysis.R     - Generates the figures, tables, and summary
                                 statistics included in the main article and
                                 appendix for the CCES data
(12) ggplot_theme.R            - Contains a simple custom ggplot2 theme
                                 function, my.theme(), to generate the figures
                                 in the ANES_Sigma_Analysis.R and 
                                 CCES_Sigma_Analysis.R files
(13) Data/                     - .rds files in this directory contain the ANES
                                 and CCES data used in model fitting and for
                                 generating summary statistics
(14) Fitted_Models/            - .rds files in this directory contain the
                                 already-fitted model objects from running the 
                                 ANES_Sigma_Models.R and CCES_Sigma_20*.R files
(15) Graphs/                   - .pdf files in this directory contain the
                                 figures outputted from the
                                 ANES_Sigma_Analysis.R and CCES_Sigma_Analysis.R
                                 files
